package com.zhang.framelib.common;

import java.io.IOException;
import java.math.BigDecimal;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

/**
 * 
 * Title:BigDecimalSerializer   BigDecimal的序列化 （异构平台可能会出现问题）
 * Description:
 * @Edit_Description:cuishuaiming
 * @version:zhang-framelib 1.0
 */
public class BigDecimalSerializer extends JsonSerializer<BigDecimal>{

	@Override
	public void serialize(BigDecimal value, JsonGenerator jgen, SerializerProvider arg2)
			throws IOException, JsonProcessingException {
		if(value != null){
			jgen.writeString(value.toString());
		}
	}
	
	@Override
	public Class<BigDecimal> handledType() {
		return BigDecimal.class;
	}

}
